package com.example

import org.apache.spark.{SparkConf, SparkContext}

object work1 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[*]").setAppName("work1")
    val sc = new SparkContext(conf)
    sc.setLogLevel("ERROR")
    val rdd = sc.textFile("C:\\Users\\Administrator\\Desktop\\data.txt")
    rdd.flatMap(_.split("\\\\00A"))
       .filter(item => item == "家电" || item == "玩具" || item == "服装")
       .map((_,1))
       .reduceByKey(_+_)
       .foreach(println(_))
  }
}